<%@ page import="org.apache.shiro.web.filter.authc.FormAuthenticationFilter" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
    <title>登录页</title>
</head>

<body>

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <form id="loginForm" action="${ctx}/login" method="post" class="form-horizontal">
                <%
                    String error = (String) request.getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME);
                    if (error != null) {
                        String expMsg = "";
                        if (error.equals("org.apache.shiro.authc.UnknownAccountException") || error.equals("org.apache.shiro.authc.IncorrectCredentialsException")) {
                            expMsg = "账号或密码错误！";
                        } else if (error.equals("com.fuyd.pms.background.service.account.IncorrectCaptchaException")) {
                            expMsg = "验证码错误！";
                        } else {
                            expMsg = "登录异常！";
                        }
                %>
                <div class="alert alert-error input-medium controls">
                    <button class="close" data-dismiss="alert">×</button>
                    <%=expMsg%>
                </div>
                <%
                    }
                %>

                <div class="form-group">
                    <label for="username" class="col-sm-2 control-label">用户名：</label>
                    <div class="col-sm-4">
                        <input id="username" name="username" class="form-control" type="text" placeholder="请输入您的用户名"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="password" class="col-sm-2 control-label">密码：</label>
                    <div class="col-sm-4">
                        <input id="password" name="password" class="form-control" type="password" placeholder="请输入您的密码"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="captcha" class="col-sm-2 control-label">验证码：</label>
                    <div class="col-sm-4">
                        <input id="captcha" name="captcha" class="form-control" type="text" placeholder="请输入验证码"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="captcha" class="col-sm-2 control-label"></label>
                    <div class="col-sm-4">
                        <img src="${ctx}/images/kaptcha.jpg">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-4">
                        <div class="checkbox">
                            <label>
                                <input id="rememberMe" type="checkbox" name="rememberMe"/> 记住我
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-4">
                        <button type="submit" class="btn btn-primary">登陆</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
